#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>

int main(int argc, char *argv[])
{
    int tcp_sock, udp_sock;
    int sock_type;
    socklen_t optlen;
    int state;

    optlen = sizeof(sock_type);
    tcp_sock = socket(AF_INET, SOCK_STREAM, 0);
    udp_sock = socket(AF_INET, SOCK_DGRAM, 0);
    printf("SOCK_STREAM: %d\n", SOCK_STREAM);
    printf("SOCK_DGRAM:  %d\n", SOCK_DGRAM);

    state = getsockopt(tcp_sock, SOL_SOCKET, SO_SNDBUF, (void *)&sock_type, &optlen);
    printf("Socket 类型 ：%d \n", sock_type);

    state = getsockopt(udp_sock, SOL_SOCKET, SO_RCVBUF, (void *)&sock_type, &optlen);
    printf("Socket 类型 : %d \n", sock_type);

    return 0;
}